package com.szh.mysobproject.viewmodel

import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import androidx.paging.*
import com.szh.mysobproject.model.UserQa
import com.szh.mysobproject.paging.source.UserQaPagingSource
import kotlinx.coroutines.flow.Flow

/**
 * @author : create by  szh
 * @date : 2022/7/8 15:06
 * @desc :问答模块
 */

class QaViewModel : ViewModel() {
    fun loadUserQaList(userId: String): Flow<PagingData<UserQa.Content>> {
        return Pager(config = PagingConfig(30),
            pagingSourceFactory = {
                UserQaPagingSource(userId)
            }).flow.cachedIn(viewModelScope)
    }
}